<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Facades\DB;

class AlterTableKfProductAddColumn extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::table("products",function (Blueprint $table){
            $table->unsignedInteger("vipPrice")->comment("菜品vip价格，分")->after("price");
            $table->unsignedInteger("costPrice")->comment("菜品成本价格，分")->after("price");
            $table->string('unit',50)->comment("菜品单位")->after('imageUrl');
            $table->index("pid","idx_pid");
            $table->index("menuId","idx_menuId");
        });
        $prefix = config('other.DB_PREFIX','');
        DB::statement("ALTER TABLE {$prefix}products AUTO_INCREMENT=100"); //自增id起始值
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::table('products', function (Blueprint $table) {
            $table->dropColumn('vipPrice');
            $table->dropColumn('costPrice');
            $table->dropColumn('unit');
        });
    }
}
